import { createSlice, createAsyncThunk } from "@reduxjs/toolkit";


export const userSlice = createSlice({
  name: "user",
  initialState: {
    token: localStorage.getItem('token') || "",
    userInfo: JSON.parse(localStorage.getItem('userInfo')) || {},
  },
  reducers: {
    loginSuccess(state, action) {
      state.token = action.payload.token;
      state.userInfo = action.payload.userInfo;
    },
  },
});

export const { loginSuccess } = userSlice.actions;
